package com.ssy.lingxi.logistics.model.request;

import com.ssy.lingxi.logistics.api.validate.InEnum;
import com.ssy.lingxi.logistics.model.enums.PricingModeEnum;
import com.ssy.lingxi.logistics.model.enums.TransportModeEnum;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import javax.validation.constraints.PositiveOrZero;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 运费模板请求实体类
 *
 * @author yzc
 * @version 2.0.0
 * @date 2020/7/14
 */
@Data
public class FreightTemplateRequest implements Serializable {

    private static final long serialVersionUID = 5838783706617934446L;

    /**
     * 主键id
     */
    @NotNull(message = "主键id不能为空", groups = {Update.class})
    private Long id;

    /**
     * 模板名称
     */
    @NotEmpty(message = "模板名称不能为空", groups = {Add.class, Update.class})
    private String name;

    /**
     * 计价方式 1-按重量
     */
    @NotNull(message = "计价方式不能为空", groups = {Add.class, Update.class})
    @InEnum(value = PricingModeEnum.class, groups = {Add.class, Update.class})
    private Integer pricingMode;

    /**
     * 运送方式 1-快递
     */
    @NotNull(message = "运送方式不能为空", groups = {Add.class, Update.class})
    @InEnum(value = TransportModeEnum.class, groups = {Add.class, Update.class})
    private Integer transportMode;

    /**
     * 重量(KG)
     */
    @Positive(message = "重量(KG)范围为0以上", groups = {Add.class, Update.class})
    private Double weight;

    /**
     * 价格(元)
     */
    @PositiveOrZero(message = "价格(元)范围为0及0以上", groups = {Add.class, Update.class})
    private BigDecimal price;

    /**
     * 每增加重量(KG)
     */
    @Positive(message = "每增加重量(KG)范围为0以上", groups = {Add.class, Update.class})
    private Double incrementWeight;

    /**
     * 每增加价格(元)
     */
    @PositiveOrZero(message = "每增加价格(元)范围为0及0以上", groups = {Add.class, Update.class})
    private BigDecimal incrementPrice;

    /**
     * 运费说明
     */
    private String explain;

    /**
     * 运费模板指定地区
     */
    List<FreightTemplateDesignateRequest> designateList;

    public interface Add {
    }

    public interface Update {
    }

    @Data
    public static class FreightTemplateDesignateRequest implements Serializable {

        private static final long serialVersionUID = 6353643190128940538L;

        /**
         * 主键id
         */
        private Long id;

        /**
         * 地区id
         */
        @NotEmpty(message = "地区编号不能为空")
        private List<String> areaIds;

        /**
         * 重量(KG)
         */
        @Positive(message = "重量(KG)范围为0以上")
        private Double weight;

        /**
         * 价格(元)
         */
        @PositiveOrZero(message = "价格(元)范围为0及0以上")
        private BigDecimal price;

        /**
         * 每增加重量(KG)
         */
        @Positive(message = "每增加重量(KG)范围为0以上")
        private Double incrementWeight;

        /**
         * 每增加价格(元)
         */
        @PositiveOrZero(message = "每增加价格(元)范围为0及0以上")
        private BigDecimal incrementPrice;
    }

}
